#ifndef DEVICES_H__
#define  DEVICES_H__

#define NR_LOGIC_DEVICES 10
#define FILE_NAME_SIZE 10
#define KEYBOARD_BUFFER_SIZE 1//256
#define TFA_SIZE 10
#define FREE 0
#define USED 1

char keyboard_buffer[KEYBOARD_BUFFER_SIZE];
int keyboard_start;
int keyboard_end;
int keyboard_count;
int buffer_pos;


struct file_operation {
  //int (*sys_open_dep)(const char *,int);
  int (*sys_read_dep)(int,char*,int);
  int (*sys_write_dep)(int,char*,int);
  int (*sys_unlink_dep)(struct logic_device *);
};

struct logic_device {
  int status;
  char name[FILE_NAME_SIZE];
  int acces_mode;
  int nref;
  struct file_operation ops;
  int first_block; /* index a la primera pagina de dades. -1 si no te cap*/
};

struct logic_device devices[NR_LOGIC_DEVICES];

struct logic_device * search_logic_device(const char *path);

/* Taula de Fitxers Oberts */
struct TFA_item {
  int nref;
  int seq_pos;
  int acces_mode;
  struct logic_device * file;
};

struct TFA_item TFA[TFA_SIZE];

struct TFA_item * get_TFA_free_entry();

void init_devices();

struct logic_device * new_file(const char * path, int flags);

void afegir_buffer_keyboard(char c);

int sys_write_console(int fd,char *buffer,int size);
int sys_read_keyboard(int fd,char *buffer,int size);
int sys_open_file(const char *path, int flags);
int sys_read_file(int fd,char *buffer,int size);
int sys_write_file(int fd,char *buffer,int size);
int sys_unlink_file(struct logic_device * file);



#endif /* DEVICES_H__*/
